package com.inwavetech.os.entity.enummap;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by jgskin on 2/28/14.
 */
abstract public class EnumMap {

    protected ArrayList<Enum> enums = new ArrayList<Enum>();
    protected ArrayList<String> ids = new ArrayList<String>();
    protected ArrayList<Integer> resources = new ArrayList<Integer>();

    private Object getFromListAByB(List listA, List listB, Object value) throws IndexOutOfBoundsException {
        return listA.get(listB.indexOf(value));
    }

    public String getId(Enum anEnum) {
        return (String) getFromListAByB(ids, enums, anEnum);
    }

    public Enum getEnum(String id) {
        return (Enum) getFromListAByB(enums, ids, id);
    }

    public void addMapping(Enum anEnum, String id, int resourceId) {
        enums.add(anEnum);
        ids.add(id);
        resources.add(resourceId);
    }

}
